#pragma once
#include "HashTable.h"

namespace bit
{
	template<class K>
	struct HashFunc
	{
		size_t operator()(const K& key)
		{
			return key;
		}
	};
	template<>
	struct HashFunc<string>
	{
		size_t operator()(const string& key)
		{
			int ret = 0;
			for (auto e : key)
			{
				ret += (e * 31);
			}
			return ret;
		}
	};

	template<class K,class V,class Hash = HashFunc<K>>
	class unordered_map
	{
	public:
		typedef typename HashBucket<K, pair<const K,V>,Hash>::Iterator iterator;
		typedef typename HashBucket<K, pair<const K, V>,Hash>::ConstIterator const_iterator;
		iterator begin()
		{
			return _ht.Begin();
		}
		iterator end()
		{
			return _ht.End();
		}
		bool insert(const K& key,const V& val)
		{
			return _ht.Insert(make_pair(key,val));
		}

		HashNode<pair<K,V>>* find(const K& key)
		{
			return _ht.Find(key);
		}
	private:
		HashBucket<K,pair<const K,V>,Hash> _ht;
	};
}